package com.tencent.compose.sample.mainpage.sectionItem


import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.ExperimentalResourceApi

@OptIn(ExperimentalResourceApi::class)
@Composable
internal fun composeView1500Page() {
    val loaded = remember { mutableStateOf(false) }
    Column(
        modifier = Modifier
            .verticalScroll(rememberScrollState())
            .fillMaxWidth(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {

        repeat(1500) { index ->
            Box(
                modifier = Modifier
                    .size(300.dp, 100.dp)
                    .border(
                        width = 2.dp,
                        color = Color.Red,
            )
                    .then(
                        if (index == 1499) Modifier.onGloballyPositioned {
                            loaded.value = true
                            //trace_tag_end()
                        } else Modifier
                    )
            ) {
                Text(
                    text = "Item #$index",
                )
            }
        }

    }
    if (loaded.value) {
        println("页面加载完成 ✅")
    }
}